const path = require("path");
const fs = require("fs");
const images = require("images");
var image = path.join(__dirname, "/images");

let files = path.join(__dirname, "/img");
var fileDir = fs.readdirSync(files);

// console.log(fileDir);
// images("./img/beef-stew-1x.jpg").size(100).save("images/i.jpg", { quality: 100 });

for (let i = 0; i < fileDir.length; i++) {
    var filePath = path.join(files, "/" + fileDir[i]);
    // console.log(fileDir[i]);
    if (fileDir[i].indexOf("jpg") > 0) {
        images(filePath)
            .size(100)
            .save(image + "/" + "@" + fileDir[i], {
                quality: 100,
            });
    }

    // images(filePath).size(100);
    // .save(image + "/" + "@" + fileDir[i], {
    //     quality: 100,
    // });
    // var file = fs.statSync(filePath);
    // console.log(file.size);
}
